﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Lamex.Base;

using DevExpress.XtraCharts;
using Lamex.mDashboard.BLL;

namespace Lamex.mDashboard.UI
{
    public partial class frmIE_Seat_ProcessAboard : DevExpress.XtraEditors.XtraForm
    {
        System.Timers.Timer t = null;

        int auto = 5;
        public frmIE_Seat_ProcessAboard()
        {
            InitializeComponent();
            txtSeat.Text = @"AR\IC单元线";
            txtTime.Text = "200s";
            this.Load += new EventHandler(frmSEATProcessAboard_Load);
            List<string> lst = new List<string>();
            lst.Add("Array");
            lst.Add("Verta");
            foreach (string str in lst) 
            cmbSlectType.Properties.Items.Add(str);
            cmbSlectType.Text = "Array";

        }
        private void frmSEATProcessAboard_Load(object sender, EventArgs e)
        {
            ShowProcessList();
            t = new System.Timers.Timer(5000);
            t.Elapsed += new System.Timers.ElapsedEventHandler(Timer_TimesUp);
            t.AutoReset = true;
            t.Enabled = true;
            t.Start();
        }
        private void Timer_TimesUp(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                try
                {
                    this.Invoke(new MethodInvoker(delegate { ShowProcessList(); }));
                }
                catch (Exception ex)
                {
                    Dispose();
                    this.Close();
                }
            }
        }
        private void ShowProcessList()
        {
            try
            {
                if (string.IsNullOrEmpty(cmbSlectType.Text))
                {
                    XtraMessageBox.Show("没有选中产品类型");
                    return;
                }
                //工位1
                //List<Lamex.Model.T3_Material> lst = t.GetBIMAList("");
                DataSet ds = BaseFactory<B_ST_ProductDefinie>.Instance.GetProcessList(cmbSlectType.Text);
                int iStandTime = 0;
                if(ds.Tables[0].Rows.Count!=0)
                {
                    //iStandTime = int.Parse(ds.Tables[0].Rows[0]["Uptime"].ToString());
                    string ProcessName ="工位2";


                    chart002.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                  
                    seriesAuto.DataSource = ds.Tables[0];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;
                    //seriesAuto.Visible = false;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart002.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart002.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    //constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色    
                    constantLine2.Title.Visible = true;
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;


                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                    //横标题设置
                    chart002.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题
                    
                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart002.Titles.Add(titles);                 //添加标题         
                }
                //工位2
                if (ds.Tables[1].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[1].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位1" ;

                    chart001.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                    seriesAuto.DataSource = ds.Tables[1];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart001.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart001.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色  
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;

                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    //横标题设置
                    chart001.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart001.Titles.Add(titles);                 //添加标题    
                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                }
                //工位3
                if (ds.Tables[2].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[2].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位" + ds.Tables[2].Rows[0]["ngNo"].ToString();

                    chart003.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                    seriesAuto.DataSource = ds.Tables[2];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart003.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart003.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色   
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "UseTime";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;
                    //横标题设置
                    chart003.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart003.Titles.Add(titles);                 //添加标题    
                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                }
                //工位4
                if (ds.Tables[3].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[3].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位" + ds.Tables[3].Rows[0]["ngNo"].ToString();

                    chart004.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                    seriesAuto.DataSource = ds.Tables[3];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart004.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart004.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    //constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色     
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "UseTime";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;
                    //横标题设置
                    chart004.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart004.Titles.Add(titles);                 //添加标题    
                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                }
                //工位5
                if (ds.Tables[4].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[4].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位" + ds.Tables[4].Rows[0]["ngNo"].ToString();

                    chart005.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                    seriesAuto.DataSource = ds.Tables[4];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart005.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart005.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    //constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色    
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "UseTime";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;
                    //横标题设置
                    chart005.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart005.Titles.Add(titles);                 //添加标题    
                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                }
                //工位6
                if (ds.Tables[5].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[5].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位5" ;

                    chart005.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                    seriesAuto.DataSource = ds.Tables[5];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart005.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart005.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine(":" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    //constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色    
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "UseTime";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;
                    //横标题设置
                    chart005.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart005.Titles.Add(titles);                 //添加标题    
                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                }
                //工位7
                if (ds.Tables[6].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[6].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位6" ;


                    chart006.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);

                    seriesAuto.DataSource = ds.Tables[6];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;
                    //seriesAuto.Visible = false;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    //seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart006.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart006.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    //constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色    
                    constantLine2.Title.Visible = true;
                    constantLine2.ShowInLegend = false;
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;

                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                    //横标题设置
                    chart006.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart006.Titles.Add(titles);                 //添加标题    
                }
               
                //工位8
                if (ds.Tables[7].Rows.Count != 0)
                {
                    //iStandTime = int.Parse(ds.Tables[7].Rows[0]["Uptime"].ToString());
                    string ProcessName = "工位" + ds.Tables[7].Rows[0]["ngNo"].ToString() + "未启用";

                    chart008.Series.Clear();

                    Series seriesAuto = new Series("", ViewType.Bar);
                    seriesAuto.DataSource = ds.Tables[7];
                    seriesAuto.ArgumentScaleType = ScaleType.Qualitative;
                    //名称
                    seriesAuto.ArgumentDataMember = "rows";
                    seriesAuto.ValueScaleType = ScaleType.Numerical;

                    //取值字段 
                    seriesAuto.ValueDataMembers.AddRange(new string[] { "UseTime" });
                    //(seriesAuto.Label as PieSeriesLabel).Position = PieSeriesLabelPosition.Outside;
                    //显示标项目名称和百分比数据
                    //seriesAuto.PointOptions.PointView = PointView.ArgumentAndValues;
                    seriesAuto.PointOptions.ValueNumericOptions.Format = NumericFormat.General;

                    seriesAuto.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//每个点都显示数据
                    //ChartTitle autoTitle = new ChartTitle();
                    //autoTitle.Text = "Hour";
                    //chartHour.Titles.Clear();
                    //chartHour.Titles.Add(autoTitle);
                    this.chart008.Series.Add(seriesAuto);
                    XYDiagram diagramhour = (XYDiagram)chart008.Diagram;
                    diagramhour.AxisY.ConstantLines.Clear();
                    ConstantLine constantLine2 = new ConstantLine("" + iStandTime.ToString(), iStandTime);
                    //constantLine2.Color = Color.Red; //直线颜色
                    //constantLine2.Title.TextColor = Color.Red;   //直线文本字体颜色    
                    constantLine2.ShowInLegend = false;
                   
                    diagramhour.AxisY.ConstantLines.Add(constantLine2);
                    diagramhour.AxisY.Title.Text = "UseTime";
                    diagramhour.AxisY.Title.Visible = false;
                    diagramhour.AxisY.Title.Alignment = StringAlignment.Center;
                    diagramhour.AxisY.Title.Antialiasing = true;
                    diagramhour.AxisY.Color = Color.Black;
                    diagramhour.AxisX.Color = Color.Black;

                    //横标题设置
                    chart008.Titles.Clear();
                    ChartTitle titles = new ChartTitle();            //声明标题

                    titles.Text = ProcessName;                            //名称
                    //titles.TextColor = System.Drawing.Color;   //颜色
                    titles.Indent = 1;                                //设置距离  值越小柱状图就越大
                    titles.Font = new Font("Tahoma", 12, FontStyle.Bold);            //设置字体
                    titles.Dock = ChartTitleDockStyle.Top;           //设置对齐方式
                    titles.Indent = 0;
                    titles.Alignment = StringAlignment.Center;       //居中对齐
                    chart008.Titles.Add(titles);                 //添加标题    
                    //diagramhour.AxisX.Title.Text = "icount";
                    //diagramhour.AxisX.Title.Visible = true;
                    //diagramhour.AxisX.Title.Alignment = StringAlignment.Center;
                    //diagramhour.AxisX.Title.Antialiasing = true;
                }
                //计算比较实际做与标准做对比,
                //if(ds.Tables[6].Rows.Count!=0)
                //{
                //    int iCount = ds.Tables[6].Rows.Count;
                //    int ihours = int.Parse(DateTime.Now.ToString("HH"));
                //    string sql = "select * from [dbo].[B_ST_TargetValue] where 1=1 and formaltime='"+ ihours + "'";
                //    DataTable dt= BaseFactory<B_ST_ProductDefinie>.Instance.GetDataTableBySql(sql);
                //    if (dt.Rows.Count != 0)
                //    {
                //        int iQty = int.Parse(dt.Rows[0]["TargetValue"].ToString());
                //        if(iQty< iCount)
                //        {
                //            labelactual.BackColor = Color.LimeGreen;
                //            labelactualBackGroup.BackColor = Color.LimeGreen;
                //            labelactualQty.BackColor= Color.LimeGreen;
                //            labelactualQty.Text = iCount.ToString();
                //        }
                //        else
                //        {
                //            labelactual.BackColor = Color.Red;
                //            labelactualBackGroup.BackColor = Color.Red;
                //            labelactualQty.BackColor = Color.Red;
                //            labelactualQty.Text = iCount.ToString();
                //        }
                //    }

                ////}
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "提示");
            }
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void btnSetting_Click(object sender, EventArgs e)
        {
            //frmSEATProcessSetting frm = new frmSEATProcessSetting();
            //frm.Show();
        }
    }
}